| 1 |  |  | import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from 'typeorm'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | import {User} from '../User/User.entity'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | export enum HolidayStatus { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |   PENDING = 'pending', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |   ACCEPTED = 'accepted', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |   REFUSED = 'refused' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | export enum HolidayLeaveType { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |   PAID = 'paid', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |   UNPAID = 'unpaid', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |   SPECIAL = 'special', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |   MEDICAL = 'medical' | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 15 |  |  | } | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | @Entity() | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  | export class Holiday { | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |   @PrimaryGeneratedColumn('uuid') | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |   private id: string; | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |   @Column('enum', {enum: HolidayStatus, nullable: false}) | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |   private status: HolidayStatus; | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |   @Column('enum', {enum: HolidayLeaveType, nullable: false}) | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |   private leaveType: HolidayLeaveType; | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |   @Column({type: 'timestamp', nullable: false}) | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |   private startDate: string; | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |   @Column({type: 'boolean', nullable: false, default: true}) | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |   private startsAllDay: boolean; | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |   @Column({type: 'timestamp', nullable: false}) | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |   private endDate: string; | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |   @Column({type: 'boolean', nullable: false, default: true}) | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |   private endsAllDay: boolean; | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |   @Column({type: 'varchar', nullable: true}) | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |   private comment: string; | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |   @Column({type: 'timestamp', nullable: true}) | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |   private moderateAt: string; | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |   @ManyToOne(type => User, {nullable: true}) | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |   private moderator: User; | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |   @ManyToOne(type => User, {nullable: false}) | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |   private user: User; | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |   constructor( | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |     user: User, | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |     leaveType: HolidayLeaveType, | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |     startDate: string, | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |     startsAllDay: boolean, | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |     endDate: string, | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |     endsAllDay: boolean, | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |     comment?: string | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |   ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |     this.status = HolidayStatus.PENDING; | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |     this.user = user; | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |     this.leaveType = leaveType; | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     this.startDate = startDate; | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |     this.startsAllDay = startsAllDay; | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |     this.endDate = endDate; | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |     this.endsAllDay = endsAllDay; | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |     this.comment = comment; | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |   public getId(): string { | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     return this.id; | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |   public getUser(): User { | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |     return this.user; | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |   public getStatus(): HolidayStatus { | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |     return this.status; | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |   public getLeaveType(): HolidayLeaveType { | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |     return this.leaveType; | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |   public getStartDate(): string { | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |     return this.startDate; | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |   public isStartsAllDay(): boolean { | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     return this.startsAllDay; | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |   public getEndDate(): string { | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |     return this.endDate; | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |   public isEndsAllDay(): boolean { | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |     return this.endsAllDay; | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |   public getComment(): string { | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |     return this.comment; | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |   public getModerator(): User { | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |     return this.moderator; | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |   public getModerateAt(): string { | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |     return this.moderateAt; | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |   } | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |   public refuse(moderator: User, date: string): void { | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |     this.status = HolidayStatus.REFUSED; | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |     this.moderator = moderator; | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |     this.moderateAt = date; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |   } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 120 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 121 |  |  |  |